package likou;

import java.util.Arrays;

/**
 * @author: 唐小尊
 * @email: 1171702529@qq.com
 * @cate: 2021/08/01 22:50
 */
public class _1337 {
    public int[] kWeakestRows(int[][] mat, int k) {
        int[][] nums = new int[mat.length][2];
        for (int i = 0; i < mat.length; i++) {
            nums[i] = new int[]{i, Arrays.stream(mat[i]).sum()};
        }
        Arrays.sort(nums, (i1, i2) -> i1[1] != i2[1] ? i1[1] - i2[1] : i1[0] - i2[0]);
        int[] res = new int[k];
        for (int i = 0; i < k; i++) {
            res[i] = nums[i][0];
        }
        return res;
    }
}
